Page({
  data: {
    value: 1,
    theme: 'light',
    ranges: [
      {
        value: 1,
        label: '公开',
        desc: '所有人可见'
      },
      {
        value: 2,
        label: '私密开',
        desc: '仅自己可见'
      }
    ]
  },
  onLoad() {
    const eventChannel = this.getOpenerEventChannel()
    eventChannel.on('init', ({value}) => {
      this.setData({ value })
    })

    this.setData({
      theme: wx.getSystemInfoSync().theme || 'light'
    })

    if (wx.onThemeChange) {
      wx.onThemeChange(({theme}) => {
        this.setData({theme})
      })
    }
  },
  
  back() {
    wx.navigateBack()
  },
  onChange(e) {
    const value = +e.detail.value
    this.setData({
      value
    })
    this.getOpenerEventChannel().emit('change', value)
    this.back()
  },
  onShareAppMessage() {
    return {
      title: '发布瞬间',
      path: '/page/publish/index'
    }
  },
})
